-
Notifications
You must be signed in to change notification settings - Fork 767
Adjust variables for banner_etc_issue #14343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The previously values with `'` would not work.
|
Skipping CI for Draft Pull Request. |
ATEX Test ResultsTest artifacts have been submitted to Testing Farm. Results: View Test Results This comment was automatically generated by the ATEX workflow. |
jan-cerny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How have you reproduced the linked issue and how have you verified that this PR fixes the issue?
I can't reproduce the issue using Automatus. However, I can see it reproduced using contest, eg. in the daily productization run today.
I have run /per-rule/oscap/from-env contest test in a custom productization pipeline on this PR and the issue still persists.
What I find suspicious in the HTML report from the initial scan is that the test scenario banner_etc_issue_disa_dod_short.pass.sh doesn't seem to modify the /etc/issue file.
|
|
||
| elif remediation_type == "bash": | ||
| pattern = r'\(bash-populate\s*(\S+)\)' | ||
| pattern = r'\(bash-populate\s*([a-zA-Z0-9_]+)\)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change needed? It doesn't change the generated data stream. Both old and new version of the shared.sh is matched by the old expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change isn't strictly needed but the old regex can get tripped up if the expression ends in )).
|
This might actually might be a contest bug in part. Around here: https://github.com/RHSecurityCompliance/contest/blob/c1620e15ee5c9d79aebb7c72b4edb50718da238c/per-rule/runner.sh#L89-L91 it seems we need to escape the @comps thoughts? This PR is still needed to fix a couple issues on the content side.
The other two commits (001b620 and 37f4731) can be dropped. Before I rebase this PR let's figure what we want to solve where. Edit: value giving us all the trouble is |
|
The section you linked https://github.com/RHSecurityCompliance/contest/blob/c1620e15ee5c9d79aebb7c72b4edb50718da238c/per-rule/runner.sh#L89-L91 seems to be related to Ansible but we have a problem when running bash remediation. I still don't understand what causes that the test scenario doesn't insert the string to |
|
@Mab879 So there are two things to address: I remember running into the first one back when I was implementing I think that broke a few tests back then (because Automatus was writing datastream files verbatim, with But my view is that Regarding the I tried to play around with So, instead, I realized we don't actually need while IFS= read -r line; do
if [[ $line =~ ^([[:space:]]+)$key: ]]; then
printf '%s%s: %s\n' "${BASH_REMATCH[1]}" "$key" "$new_value"
else
printf '%s\n' "$line"
fi
donewhich seems to do the replacement correctly: $ read -r new_value
^I've[\s\n]+read[\s\n]+&[\s\n]+consent[\s\n]+to[\s\n ]+terms[\s\n]+in[\s\n]+IS[\s\n]+user[\s\n]+agreem't\.$
$ printf '%s\n' "$new_value"
^I've[\s\n]+read[\s\n]+&[\s\n]+consent[\s\n]+to[\s\n ]+terms[\s\n]+in[\s\n]+IS[\s\n]+user[\s\n]+agreem't\.$
$ grep login_banner_text: rhel9/playbooks/all/banner_etc_issue.yml
login_banner_text: ^Authorized[\s\n]+users[\s\n]+only\.[\s\n]+All[\s\n]+activity[\s\n]+may[\s\n]+be[\s\n]+monitored[\s\n]+and[\s\n]+reported\.$
$ while IFS= read -r line; do if [[ $line =~ ^([[:space:]]+)$key: ]]; then printf '%s%s: %s\n' "${BASH_REMATCH[1]}" "$key" "$new_value"; else printf '%s\n' "$line"; fi; done < rhel9/playbooks/all/banner_etc_issue.yml | grep login_banner_text:
login_banner_text: ^I've[\s\n]+read[\s\n]+&[\s\n]+consent[\s\n]+to[\s\n ]+terms[\s\n]+in[\s\n]+IS[\s\n]+user[\s\n]+agreem't\.$--- rhel9/playbooks/all/banner_etc_issue.yml 2026-01-30 10:36:37.365885533 +0100
+++ new 2026-01-30 11:18:46.116887483 +0100
@@ -10 +10 @@
- login_banner_text: ^Authorized[\s\n]+users[\s\n]+only\.[\s\n]+All[\s\n]+activity[\s\n]+may[\s\n]+be[\s\n]+monitored[\s\n]+and[\s\n]+reported\.$
+ login_banner_text: ^I've[\s\n]+read[\s\n]+&[\s\n]+consent[\s\n]+to[\s\n ]+terms[\s\n]+in[\s\n]+IS[\s\n]+user[\s\n]+agreem't\.$I'll create a PR for Contest to fix it. Note that this solution also isn't perfect as we would ideally escape the (But, for the record, it could be done with vars:
some_var: |-1
blabla: this is fully verbatim beyond the 1 leading space
other_key: ...) |
|
I think that I now know where my confusion comes from. I focused only on the pass test scenario |
As the comment suggests, awk was interpreting at least \n and & as special and corrupting the value. See also ComplianceAsCode/content#14343 (comment) Signed-off-by: Jiri Jaburek <[email protected]>
That is correct. |
Turns out I will have to do it like that, because there are many playbooks with variables like vars:
sshd_max_auth_tries_value: 123or vars:
var_sshd_set_maxstartups: 10:30:60or vars:
var_sshd_disable_compression: noand these get converted to int/dict/bool by YAML when they should be strings, which is possibly what causes a lot of failures with the bash loop approach (which doesn't try to quote anything, unlike the |
Description:
Review each commit for details.
Rationale:
Fixes #13690
Review Hints:
Run automatus tests for